home *** CD-ROM | disk | FTP | other *** search
- # Generic Makefile for dmake
- #
- # Notes:
- #
- # The reason we have MOREINCDIRS and MOREINCDIRSR is because we need both,
- # at least as long as we're using dmake. The difference is that MOREINCDIRSR
- # has aliases resolved. We need this for the .SOURCE special targets, which
- # don't follow aliases (except in the case of a %-rule, in which case dmake
- # *does* infer the rule, but then fails to set $< correctly. But we also need
- # MOREINCDIRS, because it has no spaces in the pathnames. Pathnames with spaces
- # are apparantly impossible to manipulate properly as entire tokens, as required
- # to append ' -i ' before each one. (It's actually more complicated than this:
- # They *are* treated as tokens, but only once. And the -i step takes two
- # modifications, so you're screwed.)
- # I'm sorry I came up with such a lame workaround, but I think it does the tool
- # justice.
- # Of course, now we pregenerate everything with Perl, so no more problem.
- # It's amazing what you can accomplish when you make your own tools,
- # and you have what to make them with.
-
- .INCLUDE : "Include.mk"
-
- MAKETARGET *= "unspecified target"
- #INCDIR *= Includes
- #SRCDIR *= Sources
- PROJLABDIR *= ":"
- DEPSDIRNAME *= [Dependencies]
- OBJDIRNAME *= (Objects)
- LIBDIRNAME *= (Libraries)
- EXEDIRNAME *= (Executables)
- COMPILER *= MW
- #COMPILER *= MrC
- #COMPILER *= SC
- ARCH *= PPC
- #ARCH *= 68K
- BUILD *= Debug
- CREATOR *= '????'
-
- QQ = "
- ALLSRCS = $(SRCS) $(MORESRCS)
- OBJS-MW = $(SRCS:b:+".o")
- OBJS-SC = $(SRCS:+".o")
- #OBJS = $(OBJS-$(COMPILER))
- OBJS = $(SRCS:b:+".o")
- MOREOBJS-MW = $(MORESRCS:b:+".o")
- MOREOBJS-SC = $(MORESRCS:+".o")
- #MOREOBJS = $(MOREOBJS-$(COMPILER))
- MOREOBJS = $(MORESRCS:b:+".o")
- OBJDIR = $(PROJLABDIR)$(OBJDIRNAME):$(ARCH):$(COMPILER):$(BUILD):
- ALLOBJS = $(OBJS:^$(OBJDIR)) $(MOREOBJS:^$(OBJDIR)) $(EXTRAOBJS)
- #ALLLIBS = $(LIBS) $(SYSLIBS)
- #SRCDIRS = ":$(SRCDIR)" $(SRCSUBDIRS)
- #INCDIRS = ":$(INCDIR):" $(MOREINCDIRS)
- ALLREZS = $(MOREREZS) $(REZS)
- CC-68K-MW = MWC68K
- CC-PPC-MW = MWCPPC # not tested
- CC-68K-SC = SCpp # not tested
- CC-PPC-MrC = MrCpp # not tested
- CC = $(CC-$(ARCH)-$(COMPILER))
- DEFS-Release = -d _NO_DEBUGGING
- DEFS = $(DEFS-$(BUILD)) $(USERDEFS)
- WARN = -w off
- # Language options
- # We need exceptions, the bool type, and unix-style newline escapes.
- # MWC automatically assumes exceptions for C++ files.
- # MrC defaults to 'public' template expansion.
- CLANG-MW =
- CLANG-MrC = -EH -xa static
- CLANG-SC = -EH
- CLANG = $(CLANG-$(COMPILER)) -bool on -nomapcr
- OPT-Debug = -opt off
- OPT-Release = -opt all
- OPT = $(OPT-$(BUILD))
- CODEGEN-68K = -model far
- CODEGEN-PPC =
- CODEGEN = $(CODEGEN-$(ARCH)) -enum int $(OPT)
- DEBUGGING-Debug = -sym full
- DEBUGGING-Release = -sym off
- DEBUGGING = $(DEBUGGING-$(BUILD))
- COPTS = $(DEFS) $(WARN) $(CLANG) $(CODEGEN) $(DEBUGGING)
- IO-MW = -EOL
- IO-MrC =
- IO = $(IO-$(COMPILER))
- EXT-MW = -ext o
- EXT-MrC =
- EXT = $(EXT-$(COMPILER)) -o $(OBJDIR)
- SYSINCTOKEN-MW = -i-
- SYSINCTOKEN-SC =
- SYSINCTOKEN-MrC =
- SYSINCTOKEN = $(SYSINCTOKEN-$(COMPILER))
- INC = $(CINCLUDES) $(SYSINCTOKEN) $(CSYSINCLUDES)
- CFLAGS = $(COPTS) $(IO) $(EXT) $(INC)
- LINKAPP-68K-MW = MWLink68K -xm a
- LINKAPP-PPC-MW = MWLinkPPC -xm a
- #LINKAPP-68K-SC = ILink # -csym 'MWDB'
- LINKAPP-68K-SC = Link -csym 'MWDB'
- LINKAPP-PPC-MrC = PPCLink -xm e
- LINKAPPFLAGS-68K = -model far
- LINKAPPFLAGS-PPC =
- LINKAPPFLAGS = -t 'APPL' -c $(CREATOR) $(LINKAPPFLAGS-$(ARCH)) # -w
- LINKAPP = $(LINKAPP-$(ARCH)-$(COMPILER)) $(LINKAPPFLAGS)
- LINKLIB-68K-MW = MWLink68K -xm l
- LINKLIB-PPC-MW = MWLinkPPC -xm l
- LINKLIB-68K-SC = Lib
- LINKLIB-PPC-MrC = PPCLink -xm l
- LINKLIB = $(LINKLIB-$(ARCH)-$(COMPILER))
- LDFLAGS = $(DEBUGGING) -mf
- APPNAME = $(NAME)
- EXEDIR = $(PROJLABDIR)$(EXEDIRNAME):$(ARCH):$(COMPILER):$(BUILD):
- LIBNAME = $(NAME).lib
- LIBDIR = $(PROJLABDIR)$(LIBDIRNAME):$(ARCH):$(COMPILER):$(BUILD):
- BINARY *= $(MAKETARGET)
-
- # The default target.
- default : test binary
-
- # Used for debugging makefiles.
- test :;
- # echo BINARY = '$(BINARY)'
-
- # Make the binary file. Might be app, da, driver, coderes, tool, or lib.
- binary : $(BINARY)
-
- # Dirs are *always* out of date, because we keep bumping the date on them.
- # So we include them in front of (not in) the binary.
-
- app : objdir exedir making "$(EXEDIR)$(APPNAME)"
-
- lib : objdir libdir making "$(LIBDIR)$(LIBNAME)"
-
- # This is a hack to make sure that a failed-to-link app gets updated.
- "$(EXEDIR)Doody" :
- Echo -n '' > "$(EXEDIR)Doody"
-
- # : $(EXTRAOBJS)
- "$(EXEDIR)$(APPNAME)" : $(OBJS) $(MOREOBJS) $(ALLLIBS) $(ALLREZS) "$(EXEDIR)Doody"
- Echo -n '' > "$(EXEDIR)Doody"
- Echo 'Compiling resources...'
- Echo ">" $(subst,$(QQ), $(ALLREZS:s/ /_|_/:f:s/_|_/ /))
- Rez -a -o $(EXEDIR)$(APPNAME) $(ALLREZS)
- Echo 'Linking...'
- Echo "> $(APPNAME)"
- $(LINKAPP) $(LDFLAGS) -o $(EXEDIR)$(APPNAME) $(ALLLIBS) $(ALLOBJS)
- SetFile -a BM $(EXEDIR)$(APPNAME)
-
- "$(LIBDIR)$(LIBNAME)" : $(OBJS)
- Echo 'Linking...'
- Echo '> $(LIBNAME)'
- $(LINKLIB) $(LDFLAGS) -o $(LIBDIR)$(LIBNAME) $(ALLOBJS)
- # PlaySound "Indigo"
-
- update : objs
-
- # A phony target to compile only. It reqs a dir, so it's always out of date.
- objs : objdir $(OBJS)
-
- objdir : "$(PROJLABDIR)$(OBJDIRNAME):" "$(PROJLABDIR)$(OBJDIRNAME):$(ARCH):" "$(PROJLABDIR)$(OBJDIRNAME):$(ARCH):$(COMPILER):" "$(PROJLABDIR)$(OBJDIRNAME):$(ARCH):$(COMPILER):$(BUILD):"
- #objdir : "$(PROJLABDIR)$(OBJDIRNAME):$(ARCH):$(BUILD):"
- libdir : "$(PROJLABDIR)$(LIBDIRNAME):" "$(PROJLABDIR)$(LIBDIRNAME):$(ARCH):" "$(PROJLABDIR)$(LIBDIRNAME):$(ARCH):$(COMPILER):" "$(PROJLABDIR)$(LIBDIRNAME):$(ARCH):$(COMPILER):$(BUILD):"
- exedir : "$(PROJLABDIR)$(EXEDIRNAME):" "$(PROJLABDIR)$(EXEDIRNAME):$(ARCH):" "$(PROJLABDIR)$(EXEDIRNAME):$(ARCH):$(COMPILER):" "$(PROJLABDIR)$(EXEDIRNAME):$(ARCH):$(COMPILER):$(BUILD):"
-
- #":%:" : "$(@:d:d)" # This should work perfectly, but it doesn't. dmake sucks.
- "%:" : "$(@:d:d)" # This should work perfectly, but it doesn't. dmake sucks.
- # Echo $$* = $*
- # Echo $$@ = $@
- # Echo $$(@:d:d) = $(@:d:d)
- Echo "Creating the $* directory."
- Echo "> $*"
- NewFolder '$@'
-
- %.r : %.rsrc
- Echo "Decompiling '$(<:f)'."
- Echo "> $(@:f)"
- DeRez '$<' > '$@'
-
- %.o :| %.cc %.cpp %.cp %.c #
- # This stupid hack is required because there may be spaces in the pathname.
- Echo '> $(<:s/ /_|_/:f:s/_|_/ /)'
- $(CC) $(CFLAGS) '$<'
- # Ugly hack for MPW compilers that insist on .c.o instead of .o
- If `Exists "$(@:d)$(<:s/ /_|_/:f:s/_|_/ /).o"`
- Rename -y "$(@:d)$(<:s/ /_|_/:f:s/_|_/ /).o" "$(@:b).o"
- End If
- # PlaySound "Droplet" # This gets annoying real fast
-
- making :
- Echo "Compiling... (maybe)"
-
- # We don't need to search directories whose files specify them explicitly.
- .SOURCE.o : $(OBJDIR)
- .SOURCE.lib : ":$(LIBDIR):"
-
- .PHONY : test binary app da driver coderes tool lib objdir libdir exedir update objs making
-